;;;Place a detail call bubble with a leader and text description
;;;in the drawing.  The leader may be single or multiple lines
;;;at any angle.  The bubble will be placed with the center along
;;;the line and the edge of the bubble coincident with the end of
;;;the leader.  If a description is given a description line will
;;;be added horizontally in line with the center of the bubble and
;;;opposite of the leader.
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;              
;;;		All rights reserved without prejudice.
;;;
;;;	Copyright:	9-23-93
;;;	Edited:		2-10-2011
;;;
(DEFUN C:BL ( / pt1 mp1 mp2 numb dimsc mpb mpn bldsc clayr txht rcall skipbt)
  (setq cmde (getvar"cmdecho"))
  (setvar "cmdecho" 0)
  (setvar "cecolor" "bylayer")
  (setq txht (getvar "textsize"))
  (if gvpno nil (load"gvpno"))
  (gvpno)
  (if txtsize nil (load "txtsize" "\nFile TXTSIZE.LSP not found!"))
  (txtsize nil)
  (setq attdlg (getvar"attdia")
        ntz (* 1001 dimsc)
        numb 0
        mjrg (if mjrg mjrg "C")
        modf "SYMB"
  );setq
  (if mjrg nil (setq mjrg "C"))
  (if getstyle (getstyle "A")(progn (load "getstyle")(getstyle "A")))
  (c:svlayr)
  (setq colr lncolr)
  (c:mklayr)
      (setq pt1 (getpoint "\nStart point of leader ")
            pt1 (list(car pt1)(cadr pt1)ntz)
            mp1 pt1)
      (while
        (setq mp2 (upoint 0 "" "Next point " nil mp1))
        (progn
          (setq mp2 (list(car mp2)(cadr mp2)ntz))
          (command ".line" mp1 mp2 "")
          (setq mpn mp1)
          (setq mp1 mp2)
          (if (= numb 0)
          (progn
            (setq mpl mp2)
            (setq numb 1)
          );progn
          );if
        );progn
      );while
      (setq dis1 (* dimsc txtht)
            ang1 (+ (angle pt1 mpl)(* 0.055555 pi))
            ang2 (- (angle pt1 mpl)(* 0.055555 pi))
            spt2 (polar pt1 ang1 dis1)
            spt3 (polar pt1 ang2 dis1)
	    ldrsc (* txtht 10)
      );setq
      (command ".insert" "ldraro" pt1 ldrsc ldrsc mpl)
      (setq mpb (polar mp1 (angle mpn mp1) (* dimsc 0.25))
            bldsc1 (strcase(ustr 0 "\nDescription" nil "T"))
      );setq
      (if (eq bldsc1 "")
        nil
        (setq bldsc2 (strcase(ustr 0 "\nDescription Line 2" nil "T")))
      );if
      (setq dscsz txtht)
      (if (> (strlen bldsc1) 0)
        (progn
	  (setq colr txcolr)
          (c:mklayr)
          (setq txten1
            (list
              (cons 0 "TEXT")
              (cons 10 mpb)
              (cons 40 dscsz)
              (cons 50 (- 0(getvar"viewtwist")))
              (cons 1 bldsc1)
            );list
          );setq
          (entmake txten1)
          (setq txten1 (entget(entlast)))
          (setq txten2
            (list
              (cons 0 "TEXT")
              (cons 10 mpb)
              (cons 40 dscsz)
              (cons 50 (- 0(getvar"viewtwist")))
              (cons 1 bldsc2)
            );list
          );setq
          (entmake txten2)
          (setq txten2 (entget(entlast))
                txtbx1 (textbox txten1)
                txtbx2 (textbox txten2)
                dllen1 (+(* 1.5 dscsz)(abs(-(car(nth 1 txtbx1))(car(nth 0 txtbx1)))))
                dllen2 (+(* 1.5 dscsz)(abs(-(car(nth 1 txtbx2))(car(nth 0 txtbx2)))))
                dllen (max dllen1 dllen2)
          );setq
	  (setq ang_1 (-(* pi 2.5)(getvar"viewtwist")))
	  (setq ang_2 (-(* pi 3.5)(getvar"viewtwist")))
	  (if (> ang_1 (* 2.0 pi))
	    (setq ang_1 (- ang_1 (* 2.0 pi))
		  ang_2 (- ang_2 (* 2.0 pi)))
	  )
          (if
            (and
              (> (angle mpn mp1) ang_1)
              (< (angle mpn mp1) ang_2)
            );and
            (progn
              (setq 
                    dscl1 (polar mpb (- pi(getvar"viewtwist")) (* dimsc 0.25))
                    dscl2 (polar dscl1 (- pi(getvar"viewtwist")) dllen)
                    dang (- pi(getvar"viewtwist"))
                    dscpt1 (polar (polar dscl1 dang dllen) (-(* pi 0.5)(getvar"viewtwist")) (* dscsz 0.625))
                    dscpt2 (polar dscpt1(-(* pi 1.5)(getvar"viewtwist"))(* dscsz 2.25))
              );setq
            );progn
            (progn
              (setq 
                    dscl1 (polar mpb (- 0(getvar"viewtwist")) (* dimsc 0.25))
                    dscl2 (polar dscl1 (- 0(getvar"viewtwist")) dllen)
                    dang (- 0(getvar"viewtwist"))
                    dscpt1 (polar (polar dscl1 dang dscsz)(-(* pi 0.5)(getvar"viewtwist"))(* dscsz 0.5))
                    dscpt2 (polar dscpt1(-(* pi 1.5)(getvar"viewtwist"))(* dscsz 2.025))
              );setq
            );progn
          );if
	  (setq colr lncolr)
          (c:mklayr)
          (setq txten1
            (subst
              (cons 10 dscpt1)
              (assoc 10 txten1)
              txten1
            )
          );setq
          (entmod txten1)
          (setq txten2
            (subst
              (cons 10 dscpt2)
              (assoc 10 txten2)
              txten2
            )
          );setq
          (entmod txten2)
          (entmake
            (list
              (cons 0 "LINE")
              (cons 10 dscl1)
              (cons 11 dscl2)
            )
          );entmake
        );progn
      );if
      (if c:bub nil (load"bub"))
      (setq rcall "T"
            skipbt "1")
      (c:bub)
      (setq rcall nil
            skipbt nil)
  (c:rslayr)
  (setvar "attdia" attdlg)
  (setvar "textsize" txht)
  (getstyle "")
  (setvar "cmdecho" cmde)
  (princ)
);DEFUN C:BL
(setq C:bldr c:bl)
(princ)
